---
title: 'Shared State'
description: 'DroidAgentState - the coordination mechanism for multi-agent workflow communication.'
---

## What is Shared State?

**DroidAgentState** is a Pydantic model that serves as the **central coordination mechanism** for Droidrun's multi-agent workflow. It's a shared data structure that all agents (Manager, Executor, CodeAct, Scripter) can read from and write to.

Shared state enables:
- **Cross-agent communication**: Agents share information about actions, results, and errors
- **Progress tracking**: Step counts, action history, visited apps/screens
- **Memory management**: Agent memory, custom variables, user session data
- **Error coordination**: Error flags, escalation thresholds, error descriptions

**Key insight**: Shared state replaces complex message passing. Instead of sending data back and forth, agents update a single shared object.

## Core State Fields

```python
class DroidAgentState(BaseModel):
    # Task context
    instruction: str = ""           # Original task
    step_number: int = 0            # Current step

    # Device state
    formatted_device_state: str = ""           # Human-readable state
    current_package_name: str = ""             # Current app
    current_activity_name: str = ""            # Current screen

    # Action tracking
    action_history: List[Dict] = []            # All actions taken
    action_outcomes: List[bool] = []           # Success/failure
    summary_history: List[str] = []            # Action summaries

    # Memory
    memory: str = ""                           # Agent persistent memory

    # Planning (Manager)
    plan: str = ""                             # Current plan
    current_subgoal: str = ""                  # Current subgoal
    manager_answer: str = ""                   # Answer-type responses

    # Error handling
    error_flag_plan: bool = False              # Signal error to Manager
    error_descriptions: List[str] = []         # Error messages

    # Script execution (Scripter)
    scripter_history: List[Dict] = []          # Scripter results
    last_scripter_success: bool = True         # Last execution status

    # Custom variables
    custom_variables: Dict = {}                # User-defined data
```